package com.acce.gxsc.page.outCarList;

import com.acce.gxsc.model.WorkModel;
import com.acce.gxsc.model.loaclBean.InCarListBean;
import com.acce.gxsc.model.loaclBean.ResultBean;
import com.acce.sdk.base.mvp.BasePresenter;
import com.acce.sdk.utils.LogUtils;

import rx.Subscriber;

/**
 * Created by huxley on 2017/5/26.
 */

public class OutCarListPresenter extends BasePresenter<OutCarListView> {

    public void loadInCarList(String time) {
        WorkModel.getInstance().loadInCarList(null, null, "").subscribe(new Subscriber<ResultBean<InCarListBean>>() {
            @Override
            public void onStart() {
                if (mViewRef != null) {
                    LogUtils.logout("1111111");
                    getView().showProgressDialog("加载中...", false);
                }
            }
            @Override
            public void onNext(ResultBean<InCarListBean> datas) {
                if (mViewRef != null) {
                    getView().loadInCarListSuccess(datas.result.InCarList);

                }
            }
            @Override
            public void onCompleted() {
                if (mViewRef != null) {
                    LogUtils.logout("3333333");
                    getView().hideProgressDialog();
                }
            }
            @Override
            public void onError(Throwable e) {
                if (mViewRef != null) {
                    LogUtils.logout("4444444");
                    e.printStackTrace();
                    getView().hideProgressDialog();
                }
            }
        });
    }
}
